package com.yutao.service.matchService;

import com.yutao.domain.Player;
import com.yutao.domain.PoolPlayer;
import com.yutao.thriftMatchAPI.Match;
import org.apache.thrift.TException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MatchServiceImpl implements Match.Iface{
    @Autowired
    MatchPoolImpl matchPool;

    @Override
    public int add_player(int score, String uuid, String username, String photo, String channel_name) throws TException {
        PoolPlayer player = new PoolPlayer(score,uuid,username,photo,channel_name);
        matchPool.addPlayer(player);
        return 0;
    }

    public void work(){
        while (true){
            if (matchPool.getPoolSize()>0){
                matchPool.match(3);

            }
        }
    }
}
